﻿Imports System.IO
Imports System.Configuration.Provider
Imports System.Drawing
Imports System.Drawing.Imaging


Public MustInherit Class ComicProvider
    Inherits ProviderBase


    ''' <summary>
    ''' 获取 全部漫画
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public MustOverride Function GetComics() As List(Of Comic)

    ''' <summary>
    ''' 获取漫画
    ''' </summary>
    ''' <param name="comicId"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public MustOverride Function GetComicById(ByVal comicId As String) As Comic

    ''' <summary>
    ''' 获取 全部卷
    ''' </summary>
    ''' <param name="comicId"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public MustOverride Function GetComicVols(ByVal comicId As String) As List(Of ComicContent)

    ''' <summary>
    ''' 获取 卷
    ''' </summary>
    ''' <param name="comicId"></param>
    ''' <param name="volId"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public MustOverride Function GetComicVolById(ByVal comicId As String, ByVal volId As String) As ComicContent


    ''' <summary>
    '''  获取 全部 章
    ''' </summary>
    ''' <param name="comicId"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public MustOverride Function GetComicChapters(ByVal comicId As String) As List(Of ComicContent)

    ''' <summary>
    ''' 获取 章
    ''' </summary>
    ''' <param name="comicId"></param>
    ''' <param name="chapterId"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public MustOverride Function GetComicChapterById(ByVal comicId As String, ByVal chapterId As String) As ComicContent


    ''' <summary>
    '''  获取图片 从 章  
    ''' </summary>
    ''' <param name="comicId"></param>
    ''' <param name="chapterId"></param>
    ''' <param name="pictureId"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public MustOverride Function GetPictureFromChapter(ByVal comicId As String, ByVal chapterId As String, ByVal pictureId As String) As Picture

    ''' <summary>
    '''  获取图片 从 卷  
    ''' </summary>
    ''' <param name="comicId"></param>
    ''' <param name="volId"></param>
    ''' <param name="pictureId"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public MustOverride Function GetPictureFromVol(ByVal comicId As String, ByVal volId As String, ByVal pictureId As String) As Picture




    ''' <summary>
    ''' 获取默认图片
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Protected Friend Function GetNoImage() As Uri
        Dim filename = Path.Combine(Path.GetTempPath, "noimage.png")
        If Not File.Exists(filename) Then
            My.Resources.ComicProvider.NoImage.Save(filename, ImageFormat.Png)

        End If
        Return New Uri(filename)
    End Function

    ''' <summary>
    ''' 获取指定文件的 MIME
    ''' </summary>
    ''' <param name="filename"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Protected Friend Function GetMIMEType(ByVal filename As String) As String
        Select Case Path.GetExtension(filename)
            Case ".jpg"
                Return "image/jpeg"
            Case ".png"
                Return "image/png"
            Case ".gif"
                Return "image/gif"
            Case ".bmp"
                Return "image/bmp"

            Case Else
                Return ""
        End Select
    End Function


End Class
